/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.hbzhit.modules.act.dto;

import com.hbzhit.common.utils.CacheUtils;
import com.hbzhit.modules.act.enums.WFVariablesEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lengleng
 * @date 2018/9/25
 */
@ApiModel("流程任务DTO类")
@Getter
@Setter
public class TaskDTO {

    @ApiModelProperty("流程业务ID")
    private String businessKey;

    @ApiModelProperty("流程任务ID")
    private String taskId;

    @ApiModelProperty("流程实例ID")
    private String processInstanceId;

    @ApiModelProperty("流程定义ID")
    private String processDefKey;

    @ApiModelProperty("流程任务名称")
    private String taskName;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("操作人")
    private Long operator;

    @ApiModelProperty("操作人名称")
    private String operatorName;

    @ApiModelProperty("操作时间")
    private Date operatTime;

    @ApiModelProperty("审核意见")
    private String opinion;

    @ApiModelProperty("动作标识")
    private Integer action;

    @ApiModelProperty("动作名称")
    private String actionName;

    @ApiModelProperty("流程变量参数")
    private Map<String, Object> variables;

    @ApiModelProperty("后续节点分支")
    private List<Map> outFlags;

    public Map<String, Object> getVariables() {
        if (action != null) {
            if (variables == null) {
                variables = new HashMap<>();
            }
            variables.put(WFVariablesEnum.ACTION.getValue(), action);
        }
        return variables;
    }

    public String getOperatorName() {
        return CacheUtils.getUserCache(operator).getRealName();
    }

}
